package com.chaopei.day09;

/**
 * @Author Corday 天涯
 * @Date 2022/3/15 10:50
 * 创建取款子线程类,也就消费者角色
 */
public class ConsumerThread implements Runnable {
    //声明共享资源对象
    private  Account acc;
    //创建有参构造器
    public ConsumerThread(Account acc){
        this.acc = acc;
    }
    @Override
    public void run() {
      //完成具体取款操作
        play();
    }//run
    public  void play(){
        for(int i=0;i<10;i++){
           int temp = (int)(Math.random()*60)+40;
           acc.getMoney(temp);
            try {
                Thread.sleep((int)(Math.random()*50)+100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }//for
    }//play
}
